package pers.zc.activiti.thread.bingfa;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * @description 一个异步的方法
 * @Author Lin FuYuan
 * @date 2020/4/24
 */
public class CallableDemo implements Callable<Integer> {
    private Integer integer;
    public CallableDemo(Integer integer){
        this.integer = integer;
    }
    @Override
    public Integer call() throws Exception {
        if(integer ==3){
            System.out.println("cuowu");
//            Thread.sleep(1000000);
            throw new RuntimeException("cuowu ");
        }else{
            Thread.sleep(1000);
        }
        System.out.println(Thread.currentThread().getName());
        if(integer ==3){
            System.out.println("这是3");
        }
        return 1;
    }

    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i <10 ; i++) {
            list.add(Long.valueOf(i));
        }
        List<Long> x = new ArrayList<>();
        x.add(2L);
        x.add(3L);
        List<Long> newList = new ArrayList<>();
        for (Long s : list) {
            if(x.contains(s)){
                newList.add(s);
            }
        }
        System.out.println(newList);


    }

}
